<template>
	<view>
		<view v-if="weekFlag" class="weeks">
			<ul>
				<li @click="selectWeek(item)" :class="item.classStyle" v-for="(item,index) in weekData" :key="index"><p>{{item.week}}</p><p>{{item.time}}</p></li>
			</ul>
		</view>
		<view class="content">
			<scroll-view scroll-y="true" style="height: 20%;">
				<ul>
					<li v-for="(item,index) in data" :key="index">
						<view @click="hrefDotor(item)">{{item.mzksmc}}</view>
					</li>
				</ul>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data:[],
				weekFlag:true,
				weekData:[],
			}
		},
		onLoad() {
			//this.init();
		},
		onShow() {
			this.init();
		},
		methods: {
			init(){
				uni.showLoading({title: '加载中'})
				this.$post("/tool/getWeekTime",{},res1=>{
					if(res1.state==200){
						let listTime=res1.data;
						listTime[0].classStyle="selectWeeks";
						this.weekData=listTime;
						let ghrq=listTime[0].time;
						this.ghrq=ghrq;
						uni.hideLoading();
						this.getDept(ghrq);
					}else{
						uni.showToast({
							title:res1.message,
							icon:"none",
							duration:3000
						})
						uni.hideLoading();	
					}
				})
			},
			selectWeek(items){
				var weekDatas=this.weekData;
				for(var data in weekDatas){
					weekDatas[data].classStyle="";
				}
				items.classStyle="selectWeeks";
				var yyyy=new Date().getFullYear();
				this.getDept(items.time);
			},
			getDept(time){
				var yyyy=new Date().getFullYear();
				time=yyyy+"-"+time;
				let data={
					"ghrq00":time,
					"funid":"F07.09.02.01",
					"ywlsh0":""+new Date().getTime()
				}
				this.$postJson("/qnyesb/qnyesbproxy",data,res=>{
					if(res.state==0){
						this.data=res.data.retrieve;
					}else{
						this.data=[];
						uni.showToast({
							title:res.message,
							icon:"none",
							duration:3000
						})
					}
					uni.hideLoading();
				})
			},
			getDate(){
				
			},
			hrefDotor(item){
				if(item.sfkspb=="N"){
					//跳转到详情页
					uni.navigateTo({
						//url:'../appointmentDetail/appointmentDetail?item='+JSON.stringify(item)
						url:'../import/import?item='+JSON.stringify(item),
						success(res) {
							res.eventChannel.emit("params",item);
						}
					})
				}else{
					//跳转到医生选择页
					uni.navigateTo({
						url:'../appointment/appointment?mzksbh='+item.mzksbh+'&mzksmc='+item.mzksmc+'&ghrq='+this.ghrq,
						success(res) {
							res.eventChannel.emit("params",item);
						}
					})
				}
			}
		}
	}
</script>

<style>
.weeks{
	width: 100%;
	background-color: #FFFFFF;
	height: 90px;
	overflow-x: scroll;
	padding-top: 10px;
}
.weeks::-webkit-scrollbar { 
	width: 0 !important 
}
.weeks ul{
	white-space: nowrap;
	display: flex;
	height: 100%;
}
.weeks ul li{
	text-align: center;
	flex: 5;
	float: left;
	padding: 15px;
	background: rgba(64, 151, 255, 0.39);
	margin-left: 10px;
	border-radius: 8px;
	
}
.selectWeeks{
	background:#FFFFFF!important;
	border: 2px solid #57A4FF;
	color:#57A4FF;
}
.content{
	width: 96%;
	margin: 0 auto;
	background-color: #FFFFFF;
	margin-top: 10px;
	padding-bottom: 10px;
}
.content ul li{
	text-indent: 1em;
	height: 51px;
	line-height: 51px;
	border-bottom: 1px solid #F5F5F5;
	width:96%;
	margin: 0 auto;
	
}
</style>
